#include "Input.h"
#include <iostream>

using namespace std;

Input::Input()
{
	for(u32 i = 0; i < irr::KEY_KEY_CODES_COUNT; i++)
		keys[i] = false;
	mouse.left = false;
	mouse.right = false;
    mouse.middle = false;
}

bool Input::OnEvent(SEvent event)
{
    bool value = false;
   
  if (event.EventType == irr::EET_KEY_INPUT_EVENT)
  {
     
	 keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
     value = true;
  }
  
  if (event.EventType == irr::EET_MOUSE_INPUT_EVENT)
  {
        switch(event.MouseInput.Event)
        {
            case EMIE_LMOUSE_PRESSED_DOWN: mouse.left = true; break;
            case EMIE_RMOUSE_PRESSED_DOWN: mouse.right = true; break;
            case EMIE_MMOUSE_PRESSED_DOWN: mouse.middle = true; break;
            case EMIE_LMOUSE_LEFT_UP: mouse.left = false; break;
            case EMIE_RMOUSE_LEFT_UP: mouse.right = false; break;
            case EMIE_MMOUSE_LEFT_UP: mouse.middle = false; break;
            case EMIE_MOUSE_MOVED: mouse.X = event.MouseInput.X; mouse.Y = event.MouseInput.Y; break;
            case EMIE_MOUSE_WHEEL: mouse.wheel = mouse.wheel + event.MouseInput.Wheel; break;
        }
     value = true;
  }
  
  return value;
}
